/**
 * Created by Administrator on 2019/9/3.
 */

var h = 0;
var m = 0;
var s = 0;

var endtime = new Date('2019-09-06 10:00:00').getTime();

function  seckill() {
    var nowtime = new Date().getTime();
    var disparity = (endtime - nowtime) / 1000;
    disparity = parseInt(disparity);
    console.log(disparity);

    h = parseInt(disparity / 3600);
    m = (disparity / 60) % 60;
    m = parseInt(m);
    s = disparity % 60;


    if (h<10){
        h = '0' + h;
    }
    if (m<10){
        m = '0' + m;
    }
    if (s<10){
        s = '0' + s;
    }
    if(disparity<= 0){
        clearInterval(t);
        console.log("秒杀已结束");
    }
    document.querySelector("#h").innerHTML = h;
    document.querySelector("#m").innerHTML = m;
    document.querySelector('#s').innerHTML = s;
}
seckill();
var t = setInterval(seckill,1000);
